package online.sixfish.common.utils;

import java.text.DecimalFormat;

public class FileOpreationUtils {
    public static String fileSizeTransfer(long fileSize) {
        String mFileSize;
        DecimalFormat df = new DecimalFormat("######0.00");
        double size = (double) fileSize;
        if (size > 1024 * 1024 * 1024) {
            size = size / (1024 * 1024 * 1024);
            mFileSize = df.format(size) + " G";
        } else if (size > 1024 * 1024) {
            size = size / (1024 * 1024);
            mFileSize = df.format(size) + " MB";
        } else if (size > 1024) {
            size = size / 1024;
            mFileSize = df.format(size) + " KB";
        } else {
            mFileSize = df.format(size) + " B";
        }

        return mFileSize;
    }
}
